/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ronsicecream.pos.entities;

import com.buanalintas.bynga.entities.MasterUnit;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author user
 */
@Entity
@Table(name = "pos_master_unit")
@XmlRootElement
//@NamedQueries({
//    @NamedQuery(name = "PosMasterUnit.findAll", query = "SELECT p FROM PosMasterUnit p"),
//    @NamedQuery(name = "PosMasterUnit.findBySync", query = "SELECT p FROM PosMasterUnit p WHERE p.sync = :sync"),
//    @NamedQuery(name = "PosMasterUnit.findByUnitId", query = "SELECT p FROM PosMasterUnit p WHERE p.unitId = :unitId"),
//    @NamedQuery(name = "PosMasterUnit.findByUnitName", query = "SELECT p FROM PosMasterUnit p WHERE p.unitName = :unitName"),
//    @NamedQuery(name = "PosMasterUnit.findByUnitDescription", query = "SELECT p FROM PosMasterUnit p WHERE p.unitDescription = :unitDescription")})
public class PosMasterUnit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "sync")
    private String sync;
    @Id
    @Basic(optional = false)
    @Column(name = "unit_id")
    private Integer unitId;
    @Column(name = "unit_name")
    private String unitName;
    @Column(name = "unit_description")
    private String unitDescription;
    @JoinColumn(name = "unit_unit_type_id", referencedColumnName = "unit_type_id")
    @ManyToOne
    private PosMasterUnitType unitUnitTypeId;
    @JoinColumn(name = "unit_unit_id", referencedColumnName = "unit_id")
    @ManyToOne
    private MasterUnit unitUnitId;
    @JoinColumn(name = "unit_regional_id", referencedColumnName = "regional_id")
    @ManyToOne
    private PosMasterRegional unitRegionalId;

    public PosMasterUnit() {
    }

    public PosMasterUnit(Integer unitId) {
        this.unitId = unitId;
    }

    public String getSync() {
        return sync;
    }

    public void setSync(String sync) {
        this.sync = sync;
    }

    public Integer getUnitId() {
        return unitId;
    }

    public void setUnitId(Integer unitId) {
        this.unitId = unitId;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public String getUnitDescription() {
        return unitDescription;
    }

    public void setUnitDescription(String unitDescription) {
        this.unitDescription = unitDescription;
    }
    
   
    public PosMasterUnitType getUnitUnitTypeId() {
        return unitUnitTypeId;
    }

    public void setUnitUnitTypeId(PosMasterUnitType unitUnitTypeId) {
        this.unitUnitTypeId = unitUnitTypeId;
    }

    public MasterUnit getUnitUnitId() {
        return unitUnitId;
    }

    public void setUnitUnitId(MasterUnit unitUnitId) {
        this.unitUnitId = unitUnitId;
    }

    public PosMasterRegional getUnitRegionalId() {
        return unitRegionalId;
    }

    public void setUnitRegionalId(PosMasterRegional unitRegionalId) {
        this.unitRegionalId = unitRegionalId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (unitId != null ? unitId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PosMasterUnit)) {
            return false;
        }
        PosMasterUnit other = (PosMasterUnit) object;
        if ((this.unitId == null && other.unitId != null) || (this.unitId != null && !this.unitId.equals(other.unitId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return unitName;
//        return "com.ronsicecream.pos.entities.PosMasterUnit[ unitId=" + unitId + " ]";
    }
    
}
